home *** CD-ROM | disk | FTP | other *** search
- Path: news.clark.net!not-for-mail
- From: eamick@clark.net (Eric Amick)
- Newsgroups: comp.lang.c
- Subject: Re: Problem with stringcopy
- Date: 6 Jan 1996 17:44:30 GMT
- Organization: the end of my rope
- Message-ID: <4cmcdu$bm5@clarknet.clark.net>
- References: <4clguu$9fs@eagle.novo.dk> <yewvimppjz5.fsf@hyll.idt.unit.no> <4cmafq$bm5@clarknet.clark.net>
- NNTP-Posting-Host: explorer.clark.net
- Mime-Version: 1.0
- Content-Type: TEXT/PLAIN; charset=ISO-8859-1
- Content-Transfer-Encoding: 8bit
- X-Newsreader: TIN [UNIX 1.3 950726BETA PL0]
-
- Eric Amick (eamick@clark.net) wrote:
- >>char *Stringcopy(char *source, int startpos, size_t length)
- >>{
- >> char tmpstring[SIZEBIGENOUGH];
- >> strncpy((char *)(source+startpos),tmpstring,length);
- >> return tmpstring;
- >>}
- >
- >This won't work as written; the first two arguments to strncpy() are
- >reversed. The cast is also unnecessary.
-
- Not to mention that returning a pointer to a local array is a bad idea.
- I *KNEW* there was something I missed... ;-)
-
- --
- Eric Amick eamick@clark.net
- Columbia, MD Public key available via finger
-